package com.example.myapplication1.diyview;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.Button;

import androidx.appcompat.widget.AppCompatButton;

/**
 * Copyright (C), 2020, 重庆八进制有限公司
 *
 * @author: weng
 * @last-modifier: weng
 * @version: 1.0
 * @create-date: 2020/12/26 9:09
 * @last-modify-date: 2020/12/26 9:09
 * @description:
 */
public class MyButton extends AppCompatButton {


    private float mInitY;
    private float mLastMotionY;

    public MyButton(Context context) {
        super(context);
    }

    public MyButton(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public MyButton(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @Override
    public boolean onTouchEvent(MotionEvent event) {


//        switch (event.getAction()) {
//
//            case MotionEvent.ACTION_DOWN:
//                mInitY = event.getRawY();
//                break;
//            case MotionEvent.ACTION_MOVE:
//                mLastMotionY = event.getRawY();
//                float detalY = mLastMotionY - mInitY;
//                mInitY = mLastMotionY;
//                Log.e("tag","getY--->"+getY());
//                setY(getY() +detalY);
//                break;
//        }


        return super.onTouchEvent(event);


    }
}
